my $genome=$ARGV[0];
my $file=$ARGV[1];
my $snp_file=$ARGV[2];
my @quals=(20);
foreach my $qual(@quals){
my $output = $file.".postprocess.summary.qual-$qual.txt";
my $newVcf = $file.".filter.noSB.qual-$qual.afterPostprocess.vcf";
my $range;
my $header = "#PBS -q lairdprio\n";
$header .= "#PBS -l walltime=300:00:00,mem=16g,nodes=1:ppn=12,arch=x86_64\n";
$header .= "#PBS -N VCF-postprocess-$file-qual-$qual\n";
#$header .= "#PBS -W depend=afterany:1652168.hpc-pbs\n";
$header .= "#PBS -j oe\n";
$header .= "cd \$PBS_O_WORKDIR\n";	
$header .= "java -Xmx16g -jar /home/uec-00/yapingli/software/BisSNP/BisSNP-0.68.4.jar -T VCFpostprocess ";
if($genome eq "hg19"){
	$header .= "-R /export/uec-gs1/laird/shared/research/yaping/data/genome_data/genome/hg19/hg19_rCRSchrm.fa ";
	$range = "/home/uec-00/shared/publicationData/bissnp2011/whole_genome_interval_list.hg19.bed";
}
elsif($genome eq "hg18"){
	$header .= "-R /export/uec-gs1/laird/shared/research/yaping/data/genome_data/genome/hg18/hg18_unmasked.plusContam.fa ";
	$range = "/home/uec-00/shared/publicationData/bissnp2011/whole_genome_interval_list.hg18.bed";
}
elsif($genome eq "mm9"){
	$header .= "-R /export/uec-gs1/laird/shared/research/yaping/data/genome_data/genome/mouse/mm9.fa ";
	$range = "/home/uec-00/shared/publicationData/bissnp2011/whole_genome_interval_list.mm9.bed";
}

$header .= "-qual $qual -L $range ";
#$header .= "-qual $qual -sb -0.02 -maxCov 120 -qd 1.0 -mq0 0.1 -minCT 1 -L $range -nt 12 ";



$header .= "-oldVcf $file ";
$header .= "-snpVcf $snp_file ";
$header .= "-newVcf $newVcf ";
$header .= "-o $output \n";

my $outfileName = "submitPBS" . $file;
open(OUT, ">$outfileName") or die "can not open file:$!";
print OUT $header;
#print $header;
close OUT;
system("qsub $outfileName");
print "$progName is submitted\n";
system("rm $outfileName");	

}
